package com.neuedu.controller;


import com.neuedu.pojo.Result;
import com.neuedu.pojo.TBed;
import com.neuedu.pojo.TElder;
import com.neuedu.service.ITBedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhangsan
 * @since 2024-06-17
 */
@RestController
@RequestMapping("/bed")
public class TBedController {
    @Autowired
    ITBedService bedService;

    @GetMapping("/page")
    public Result<List<TBed>> getPage(@RequestParam(name = "currentPage", defaultValue = "1") Integer currentPage,
                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                      // 需要条件查询的字段数据
                                      @RequestParam(name = "bedNumber", defaultValue = "", required = false) String bedNumber,
                                      @RequestParam(name = "bedStatus", defaultValue = "", required = false) Integer bedStatus) {
        return bedService.getPage(currentPage, pageSize, bedNumber, bedStatus);
    }
    @PostMapping("/add")
    public Result addBed(@RequestBody TBed bed){
        return bedService.addBed(bed);
    }
    @PostMapping("/modstatus")
    public Result modStatusByBedId(@RequestParam(name = "bedId") Integer bedId){
        return bedService.modStatusByBedId(bedId);
    }
    @PostMapping("/deletebed")
    public Result deletebed(@RequestParam(name = "bedId") Integer bedId){
        return bedService.deletebed(bedId);
    }
}
